package com.treehouse.sql;

import java.sql.Connection;

public abstract class Database {

	private String name = null;
	private String host = null;
	private int port;
	private String username = null;
	private String password = null;
	private Connection connection = null;

	public Database(String name, String host, int port) {
		this.name = name;
		this.host = host;
		this.port = port;
	}

	public Database(String name, String host, int port, String username,
			String password) {
		this.name = name;
		this.host = host;
		this.port = port;
		this.username = username;
		this.password = password;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getHost() {
		return host;
	}

	public void setHost(String host) {
		this.host = host;
	}

	public int getPort() {
		return port;
	}

	public void setPort(int port) {
		this.port = port;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public Connection getConnection() {
		if (this.connection == null)
			this.connect();
		return connection;
	}

	protected void setConnection(Connection connection) {
		this.connection = connection;
	}

	protected abstract void connect();
}
